import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author lys
 * 管理员信息界面
 */
public class AdminProfile {
    private static AdminProfile instance;
    public JPanel jPanel = new JPanel();
    public JLayeredPane  jLayeredPane = new JLayeredPane();
    public JPanel jPanel2 = new JPanel();
    // 标签
    private JLabel jLabel = new JLabel("账户管理");
    // 按钮
    private JButton button = new JButton("修改信息");
    //private JButton button2 = new JButton("借书记录");
    private JButton button2 = new JButton("退出登录");
    // 字体
    private Font font = new Font("宋体", Font.BOLD, 60);
    private Font font1 = new Font("宋体", Font.BOLD, 25);
    private Font font2 = new Font("宋体", Font.BOLD,40);

    String s1=null;
    String s2=null ;
    String s3=null ;
    private JLabel jLabel1;
    private JLabel jLabel2;
    private JLabel jLabel3;

    private String user;
    private JFrame frame;
    private AdminProfile() {
        // 改变背景图片
        jLabel1 = new JLabel("  姓名 :"+Admin.getInstance().getName());
        jLabel2 = new JLabel("  学号 :"+Admin.getInstance().getSid());
        jLabel3 = new JLabel("登录名 :"+Admin.getInstance().getUsername());
        Icon i = new ImageIcon(AdminProfile.class.getResource("img/8.jpg"));
        JLabel Label = new JLabel(i);
        Label.setBounds(0, 0, 1200, 800);
        // 面板布局为空
        jPanel2.setLayout(null);
        // 标签

        jLabel.setFont(font);
        jLabel.setBounds(460, 50, 800, 70);
        jLabel.setForeground(Color.white);
        jLabel1.setBounds(500,230,400,50);
        jLabel1.setForeground(Color.white);
        jLabel1.setFont(font2);
        jLabel2.setBounds(500,330,400,50);
        jLabel2.setForeground(Color.white);
        jLabel2.setFont(font2);
        jLabel3.setBounds(500,430,400,50);
        jLabel3.setForeground(Color.white);
        jLabel3.setFont(font2);
        // 按钮
        button.setFont(font1);
        button2.setFont(font1);
       // button3.setFont(font1);

        button.setBounds(150, 250, 250, 50);
        button2.setBounds(150, 310, 250, 50);
      //  button3.setBounds(150, 370, 250, 50);


        button.setBackground(Color.white);
        button2.setBackground(Color.white);
      //  button3.setBackground(Color.white);


        button.setForeground(Color.white);
        button2.setForeground(Color.white);
       // button3.setForeground(Color.white);


        button.setOpaque(false);
        button2.setOpaque(false);
      //  button3.setOpaque(false);


        jPanel2.add(button);
        jPanel2.add(button2);
     //   jPanel2.add(button3);

        jPanel2.add(jLabel);
        jPanel2.add(jLabel1);
        jPanel2.add(jLabel2);
        jPanel2.add(jLabel3);
        jPanel2.add(Label);
//        jLayeredPane.add(button);
//        jLayeredPane.add(button2);
//        jLayeredPane.add(button3);
//
//        jLayeredPane.add(jLabel);
//        jLayeredPane.add(jLabel1);
//        jLayeredPane.add(jLabel2);
//        jLayeredPane.add(jLabel3);
//        jLayeredPane.add(Label);

        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                AdminInterface.getInstance().admin.setVisible(false);
                AdminEditProfile.getInstance().setVisible(true);
            }
        });

        button2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                AdminInterface.getInstance().admin.dispose();
                AdminInterface.removeInstance();
                ManageBook.removeInstance();
                AddBook.removeInstance();
                UpdateBook.removeInstance();
                DeleteBook.removeInstance();
                AddType.removeInstance();
                UpdateType.removeInstance();
                DeleteType.removeInstance();
                ManageUser.removeInstance();
                CloseUser.removeInstance();
                CheckBorrowRecords.removeInstance();
                AdminEditProfile.removeInstance();
                AdminProfile.removeInstance();
                Login.getInstance().setVisible(true);
                Login.loginUser="";
            }
        });

        button.setFocusPainted(false);
        button2.setFocusPainted(false);
    }
    public static AdminProfile getInstance() {
        if(instance == null) instance = new AdminProfile();
        return instance;
    }
    public static void removeInstance(){
        instance = null;
    }
}
